﻿using RotovapPlatform.Domain.Business.Recipes.Entities.Parameters;
using RotovapPlatform.Domain.Business.Recipes.Entities;
using System.Collections.ObjectModel;

namespace RotovapPlatform.Domain.Recipes.Services;

/// <summary>
/// 配方领域服务接口
/// </summary>
public interface IRecipeDomainService
{
	/// <summary>
	/// 验证配方参数
	/// </summary>
	/// <param name="recipe">待验证的配方</param>
	/// <returns>验证结果和错误信息</returns>
	(bool IsValid, string ErrorMessage) ValidateRecipe(RecipeDefinition recipe);

	/// <summary>
	/// 异步验证配方参数
	/// </summary>
	/// <param name="recipe">待验证的配方</param>
	/// <returns>验证结果和错误信息</returns>
	Task<(bool IsValid, string ErrorMessage)> ValidateRecipeAsync(RecipeDefinition recipe);

	/// <summary>
	/// 计算配方总执行时间
	/// </summary>
	/// <param name="recipe">配方定义</param>
	/// <returns>预计执行时间</returns>
	TimeSpan CalculateTotalExecutionTime(RecipeDefinition recipe);

	/// <summary>
	/// 验证配方执行条件
	/// </summary>
	/// <param name="recipe">配方定义</param>
	/// <returns>是否可执行和原因</returns>
	(bool CanExecute, string Message) ValidateExecutionConditions(RecipeDefinition recipe);

	/// <summary>
	/// 验证产物参数
	/// </summary>
	/// <param name="parameters">产物参数集合</param>
	/// <returns>验证结果和错误信息</returns>
	(bool IsValid, string ErrorMessage) ValidateProductParameters(
		ObservableCollection<ProductParameters> parameters);

	/// <summary>
	/// 异步验证产物参数
	/// </summary>
	/// <param name="parameters">产物参数集合</param>
	/// <returns>验证结果和错误信息</returns>
	Task<(bool IsValid, string ErrorMessage)> ValidateProductParametersAsync(
		ObservableCollection<ProductParameters> parameters);

	/// <summary>
	/// 验证物料和清洗液是否存在于货架上
	/// </summary>
	/// <param name="recipe">配方定义</param>
	/// <returns>验证结果和错误信息</returns>
	Task<(bool IsValid, string ErrorMessage)> ValidateMaterialsExistenceAsync(RecipeDefinition recipe);

	/// <summary>
	/// 验证实验组中的物料位置是否有重复
	/// </summary>
	/// <param name="recipes">配方列表</param>
	/// <returns>验证结果和错误信息</returns>
	Task<(bool IsValid, string ErrorMessage)> ValidateMaterialLocationsAsync(IEnumerable<RecipeDefinition> recipes);
}